const getters = { //向外暴露【像计算属性一样】
	statusHeight: i => i.system.statusBarHeight,
	titleBarHeight: j => j.system.titleBarHeight,
	foldState: k => k.system.foldState,
	bodyBarHeight: state => {
		if (state.system.foldState) return state.system.titleBarHeight;
		return 100;
	},
	totalHeight: state => {
		if (state.system.foldState) {
			return state.system.statusBarHeight + state.system.titleBarHeight + 15;
		}
		return state.system.statusBarHeight + state.system.titleBarHeight + 100 + 15;
	},
	carList: state => state.car.carList,
	totalPrice: price => {
		return price.car.carList.reduce((prev, next) => { //将一个数组中的每个元素汇总为一个单一的值
			return prev += next.price * next.numvalue;
		}, 0)
	},
	buyNum: num => {
		return num.car.carList.reduce((prev, next) => {
			return prev + next.numvalue
		}, 0)
	},
	addressObj: i => i.address.addressObj,
	cheap: cheap => {
		return cheap.car.carList.filter(item => {
			return item.preprice > 0 //是==艹
		}).reduce((prev, i) => {
			return (i.preprice - i.price) * i.numvalue + prev;
		}, 0);
	}
}
export default getters;
